/*
 * acm2476.c
 *
 *  Created on: 5 Apr 2010
 *      Author: xuxu
 */

#include<stdio.h>
#include<string.h>

double count(char *s)
{
	int len;
	int i;
	double xiao;
	len=strlen(s);
	double ret=0;
	xiao=1;
	for(i=0;i<len;i++)
	{
		if(s[i]>='0'&&s[i]<='9')
			ret=ret*10+s[i]-'0';
		else if('.'==s[i])
			break;
	}
	for(;i<len;i++)
	{
		if(s[i]>='0'&&s[i]<='9')
		{
			xiao*=10;
			ret+=(s[i]-'0')/xiao;
		}
	}
	return ret;
}

int main()
{
	double result;
	double tmp;
	char num[50];
	int len;
	int n;
	int i,j;
	while(scanf("%d",&n)&&n!=0)
	{
		result=0;
		for(i=0;i<n;i++)
		{
			scanf("%s",num);
			result+=count(num);
		}
		sprintf(num,"%.2lf",result);
		len=strlen(num);
		printf("$");
		j=1;
		for(i=0;i<len;i++)
		{
			printf("%c",num[i]);
			if(0<=len-6-i)
			{
				if(0==(len-6-(i+1))%3)
					printf(",");
			}
		}
		printf("\n");
	}
	return 0;
}
